{include file='common/head.html'}
<link rel="stylesheet" href="{APP_THEME_DIR}/zTree_v3/css/zTreeStyle/zTreeStyle.css?v=1" type="text/css">
<script type="text/javascript" src="{APP_THEME_DIR}/zTree_v3/js/jquery.ztree.core.min.js"></script>
<style>
    html,body {
        height: 100%;
    }
    body {
        overflow-x: hidden;
    }
    .allshow {
        padding: 10px 6px 6px;
        font-size: 13px;
        color: #333;
        cursor: pointer;
    }
    .allshow i {
        font-style: normal;
        border: 1px solid #ddd;
        width: 12px;
        height: 12px;
        display: inline-block;
        line-height: 12px;
        text-align: center;
        color: #333;
        margin: 0 4px;
    }
    #aside {
        width: 170px;
        background: #f9f9f9;
        padding: 5px 0 20px;
        overflow: hidden;
        border-right: 2px solid #ededed;
        height: 100%;
        box-sizing: border-box;
    }
    #content_main {
        position: absolute;
        margin: 0px;
        inset: 0px 0px 0px 170px;
        width: calc(100% - 170px);
        z-index: 0;
        display: block;
        visibility: visible;
        background: #FFF;
        padding: 0px;
        height: 100%;
        right: 0;
            top: 0;
    }
    #content_body {
        height: 100%;
    }
    .pReload {
        padding-left: 10px;
        font-size: 12px;
        margin-bottom: 5px;
        cursor: pointer;
        color: #999;
    }
    .pReload:hover {
        color: #333;
    }
    .ztree {
        padding: 0 8px 20px;
    }
    .ztree li {
        line-height: 26px;
    }
    .ztree .node_name {
        font-size: 13px !important;
    }
    .ztree li a {
        vertical-align: middle;
    }
    .ztree li a .node_name {
        vertical-align: top;
    }
    #aside:hover {overflow-y: auto;}
    #aside:hover .ztree{overflow-x: auto;}
    /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
    ::-webkit-scrollbar{
        width: 6px;
        height: 6px;
        background-color: #F5F5F5;
    }

    /*定义滚动条轨道 内阴影+圆角*/
    ::-webkit-scrollbar-track {
        box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
        -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
        border-radius: 10px;
        background-color: #F7F7F7;
    }

    /*定义滑块 内阴影+圆角*/
    ::-webkit-scrollbar-thumb{
        border-radius: 10px;
        box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
        -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
        background-color: #c8c8c8;
    }
    @media (max-width: 1366px) {
        .ztree .node_name {
            font-size: 12px !important;
        }
    }
</style>


<script>
    var zNodes = [
        {foreach $sorts(key,value)}
        {if($value->type==1)}
        {id: [value->scode], pId: [value->pcode], {if(!$value->son)}icon:"{APP_THEME_DIR}/images/tree/attibutes.png",{/if} name: '{php}echo htmlspecialchars_decode($value->name){/php}', url: '{if($value->son && $value->outlink)}javascript:;{else}{url./admin/Single/mod/mcode/'.$value->mcode.'/id/'.get_single_id($value->scode).'}{/if}', target: 'content_body', {if($value->pcode==0)}open: true,{/if} {if($value->son)}isParent: true{else}isParent: false{/if}},
        {/if}
        {if($value->type==2)}
        {id: [value->scode], pId: [value->pcode], {if(!$value->son)}icon:"{APP_THEME_DIR}/images/tree/administrative-docs.png",{/if} name: '{php}echo htmlspecialchars_decode($value->name){/php}', url: '{url./admin/Content/index/mcode/'.$value->mcode.'/scode/'.$value->scode.'}', target: 'content_body', {if($value->pcode==0)}open: true,{/if} {if($value->son)}isParent: true{else}isParent: false{/if}},
        {/if}
        {/foreach}
    ];

    var setting = {
        view:{
            dblClickExpand:false
            ,showLine:true
            ,showIcon: {if([$ztreeicon])}true{else}false{/if}
        },
        data:{
            simpleData:{
                enable:true
            }
        },
        callback:{
            beforeExpand:beforeExpand
            ,onExpand:onExpand
            ,onClick:onClick
        }
    };
    var curExpandNode=null;
    function beforeExpand(treeId,treeNode) {
        var pNode=curExpandNode?curExpandNode.getParentNode():null;
        var treeNodeP=treeNode.parentTId?treeNode.getParentNode():null;
        var zTree=$.fn.zTree.getZTreeObj("tree");
        for(var i=0,l=!treeNodeP?0:treeNodeP.children.length;i<l; i++){
            if(treeNode!==treeNodeP.children[i]){zTree.expandNode(treeNodeP.children[i],false);}
        };
        while (pNode){
            if(pNode===treeNode){break;}
            pNode=pNode.getParentNode();
        };
        if(!pNode){singlePath(treeNode);}
    };
    function singlePath(newNode) {
        if (newNode === curExpandNode) return;
        if (curExpandNode && curExpandNode.open==true) {
            var zTree = $.fn.zTree.getZTreeObj("tree");
            if (newNode.parentTId === curExpandNode.parentTId) {
                zTree.expandNode(curExpandNode, false);
            } else {
                var newParents = [];
                while (newNode) {
                    newNode = newNode.getParentNode();
                    if (newNode === curExpandNode) {
                        newParents = null;
                        break;
                    } else if (newNode) {
                        newParents.push(newNode);
                    }
                }
                if (newParents!=null) {
                    var oldNode = curExpandNode;
                    var oldParents = [];
                    while (oldNode) {
                        oldNode = oldNode.getParentNode();
                        if (oldNode) {
                            oldParents.push(oldNode);
                        }
                    }
                    if (newParents.length>0) {
                        zTree.expandNode(oldParents[Math.abs(oldParents.length-newParents.length)-1], false);
                    } else {
                        zTree.expandNode(oldParents[oldParents.length-1], false);
                    }
                }
            }
        }
        curExpandNode = newNode;
    };

    function onExpand(event,treeId,treeNode){curExpandNode=treeNode;};
    
    function onClick(e,treeId,treeNode){
        var zTree=$.fn.zTree.getZTreeObj("tree");
        zTree.expandNode(treeNode,null,null,null,true);
    }

    $(function(){
        $.fn.zTree.init($("#tree"),setting,zNodes);
        $(".ui-layout-north li:first-child").click();
    });

    function expandAll(obj){
        var expand = $(obj).attr('data-expand');
        var zTree = $.fn.zTree.getZTreeObj("tree");
        if ('shrink' == expand) { // 展开时收缩
            zTree.expandAll(false);
            $(obj).attr('data-expand', 'spread').attr('title', '点击全部展开').html('<i>+</i>全部展开');
        } else { // 收缩时展开
            zTree.expandAll(true);
            $(obj).attr('data-expand', 'shrink').attr('title', '点击全部收缩').html('<i>─</i>全部收缩');
        }
    }
</script>

<div id="aside">
     <div class="allshow" onclick="expandAll(this);" data-expand="init" title="点击全部展开"><i>+</i>全部展开</div>
    <ul id="tree" class="ztree"></ul>
</div>

<div id="content_main">
    <iframe name="content_body" id="content_body" src="{url./admin/Index/contenthome}" frameborder="0" width="100%" height="100%">
    </iframe>
</div>
<!-- 右侧主体结束 -->
<script>
    window.onload = function() {
        $('.node_name').each(function(){
            var reg=new RegExp("&#039;","g"); //创建正则RegExp对象   
            var stringObj=$(this).text();   
            var newstr=stringObj.replace(reg,"'");   
            $(this).text(newstr);
        })
    }
</script>
{include file='common/foot.html'}